<?php
	class Config
	{
		var $DB_HOST	= "localhost";
		var $DB_USER	= "root";
		var $DB_PASS	= "";
		var $DB_NAME	= "blogscript";
		var $DB_PREFIX	= "";
		private $connection;
		
		function __construct() 
		{
			$this->open_connection();
			//echo 'Set connect.';
		}

		private function open_connection() 
		{
			$this->connection = mysql_connect($this->DB_HOST,$this->DB_USER,$this->DB_PASS);
			if(!$this->connection) 
			{
				die("Database connection failed: ". mysql_error());
				exit;
			} 
			else 
			{
				try 
				{
					$db_select = mysql_select_db($this->DB_NAME);
					$db_select;
				}
				catch (Exception $e)
				{
					echo $e->getMessage(), "\n In connect";
					exit;
				}
			}
			mysql_query("set names utf8") or die("set names utf8 failed");
		}

		public function sql($query) 
		{
			try 
			{
				return mysql_query($query, $this->connection);
				
			}
			catch (Exception $e)
			{
				echo $e->getMessage(), "\n In sql query";
				exit;
			}
			//return $result;
		}
	}
?>